import Vue from 'vue'
import './plugins/fontawesome'
import './plugins/axios'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import './plugins/axios.js'
import './plugins/fontawesome.js'
import App from "./App";
import axios from 'axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'




// const permissions = JSON.parse(window.sessionStorage.getItem('rolePermission'))
// Vue.directive('hasPermission', {
//   bind (el, binding) {
//     if (!permissions.includes(binding.value)) {
//       el.style.display = 'none'
//     }
//   }
// })

axios.interceptors.request.use(config => {
  NProgress.start()
  // console.log(config)
  // 为请求头对象，添加token验证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')

  // 在最后必须 return config
  return config
})

// response 拦截器中,  隐藏进度条NProgress.done()
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})

// axios.defaults.baseURL = 'http://49.232.173.48:8080'

axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.headers.get['Content-Type'] = 'application/x-www-form-urlencoded';


Vue.prototype.$http = axios
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
